By John Halleck, University of Utah Computer Center
General Hype
The mouse driven keyboard (KeyMouse) is a desk accessory program for the Apple® Macintosh™ family of computers. It is compatible with the 128K, 512K, and Macintosh Plus. It requires no special system, and runs with any program that supports desk accessories in the normal manner.
"Head Mounted Mouse" hardware has been available for the Macintosh computers for some time now. This makes many features of the Mac accessible to handicapped users, but still leaves the problem of typing. The Mac has a "Desk Accessory" (DA) called KeyCaps that is a step in the right direction, but still leaves much to be desired.
The KeyCaps DA is always the front window when in use, which means that even if it did pass characters to a program it could not tell which window that they were meant for. KeyCaps does not work while modal dialog boxes are active, and does not forward any command sequences. In addition, KeyCaps does not give any way to type character combinations such as "Shift-letter", or "Option-letter", without using the physical keyboard.
The KeyMouse DA allows the user to perform all keyboard functions with an onscreen version of the standard keyboard. The user types a character by moving the cursor to it and clicking the mouse on the desired key. The Caps Lock, Shift, Option, and Command keys are all latching ("sticky") keys, allowing combinations such as "Option-G" to be typed. The Command-key menu combinations also work with the KeyMouse DA. The physical keyboard can be used in conjunction with the screen keyboard. The KeyMouse keyboard continues to function with the dialog boxes, and can be used to enter text and numbers into them. In addition the program updates the systems keyboard memory so that the user can perform the "Shift-click" and "Option-click" mouse functions that some programs require. The KeyMouse keyboard continues to function with the dialog boxes, and can be used to enter text and numbers into them. Except for getting keys to repeat, almost anything that can be down from the physical keyboard can be down from the KeyMouse DA.
Internal Workings
The first thing that KeyMouse does is to make the system changes needed to allow it to remain the back window even though it is being used. This change is required to allow the program's window to remain foremost. Generally the system tries to move the currently active window to the front. Many programs decide what to do with a keyboard event based on which window is in front, and if KeyMouse's window were foremost, then many programs would give the events to it instead of handling them itself. All system changes that KeyMouse makes are removed when either the program or the desk accessory finally finishes.
Originally it was planned to have the program catch mouse-down events in the normal manner, and generate keyboard events from them. It was discovered that, during the system's dialogs with the user, desk accessories were not given the events. So the following alternate plan was adopted.
KeyMouse gains control sixty times each second. It checks to see if the state of the mouse is the same as in the previous check. If the state is different, it checks to see if the mouse is in a visible part of its window. If the change is in a visible part of its window, then it updates the system's keyboard map, and generates the keyboard event. For latching keys it doesn't generate the event, but does update the keyboard map.
Most of the code in KeyMouse deals with drawing and labeling the keyboard. There is a smaller section of code that figures out where the user is pointing, and the remaining code handles posting the event and general housekeeping.
KeyMouse contains a table that tells it the configuration of the keyboard. It produces the onscreen keyboard image from this table, and so could be set up with non-standard keyboard arrangements by merely changing the layout table. Various sizes of keyboard can be produced by a simple table change.
Since it uses the system's routines to do keyboard-to-character mapping, KeyMouse will automatically use whatever mapping that the user's program has installed. The labeling of the onscreen keyboard reflects whatever mapping is in effect.